﻿@using WeatherForecast.Mvc.Areas.Administration.ViewModels
@{
    ViewBag.Title = "Index";
}

<h2>Towns</h2>

@(Html.Kendo()
    .Grid<AdminTowns>()
    .Name("grid-towns")
    .Columns(columns =>
    {
        columns.Bound(model => model.Id);
        columns.Bound(model => model.Name);
        columns.Bound(model => model.AreaName);
        columns.Command(command =>
            {
                command.Edit();
                command.Destroy();
            });
    })
    .ToolBar(tool =>
        {
            tool.Create();
        })
    .Pageable(page =>
        {
            page.PreviousNext(true);
            page.Numeric(true);
        })
    .Sortable(sort =>
        {
            sort.AllowUnsort(false);
            sort.SortMode(GridSortMode.SingleColumn);
        })
    .Groupable()
    .Filterable()
    .Resizable(resize => resize.Columns(true))
    .Navigatable()
    .Editable(edit =>
        {
            edit.Mode(GridEditMode.PopUp);            
        })
    .Selectable(select => select.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Cell))    
    .DataSource(data =>
    {
        data.Ajax()
            .Model(m => m.Id(b => b.Id))
            .PageSize(10)
            .ServerOperation(true)           
            .Read("ReadTown", "Towns")
            .Update("EditTown", "Towns")
            .Create("CreateTown", "Towns")
            .Destroy("DeleteTown", "Towns");
            
    }))

